<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>ECharts</title>
    <script src="../static/echarts/echarts.min.js"></script>
    <script src="../static/layui/layui.js" charset="utf-8"></script>
</head>
<body>
<div id="main" style="width: 600px;height:400px;"></div>
<script type="text/javascript">
    layui.use(['form', 'layedit', 'laydate'], function() {
        $ = layui.jquery
        $.ajax({
            url: "/pokemon1",
            dataType: "json",
            type:"get",
            success: function (d) {
                console.log(d.pokemon)
                var d1 = d.pokemon.fire;
                var d2 = d.pokemon.water;
                var d3 = d.pokemon.grass;
                var d4 = d.pokemon.electric;
                var d5 = d.pokemon.ground;
                // 基于准备好的dom，初始化echarts实例
                var myChart = echarts.init(document.getElementById('main'));

                // 指定图表的配置项和数据
                var option = {
                    title: {
                        text: 'ECharts 入门示例'
                    },
                    tooltip: {},
                    legend: {
                        data: ['销量']
                    },
                    xAxis: {
                        data: ["火系", "水系", "草系", "电系", "地面系"]
                    },
                    yAxis: {},
                    series: [{
                        name: '宝可梦数量',
                        type: 'bar',
                        data: [d1, d2, d3, d4, d5]
                    }]
                };

                // 使用刚指定的配置项和数据显示图表。
                myChart.setOption(option);
            }
        })
    });
</script>
</body>
</html>